package com.linux.huhx.thread;

import ch.qos.logback.core.util.TimeUtil;

import java.util.concurrent.TimeUnit;

/**
 * @Author: huhx
 * @Date: 2017-11-24 上午 10:18
 */
public class HelloRunnable implements Runnable {

    @Override
    public void run() {
        try {
            System.out.println("Hello from a thread!");
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(new HelloRunnable());
        thread.start();

        //
        TimeUnit.SECONDS.sleep(3);
        System.out.println(thread.getName());
        thread.start();
        System.out.println("In main method.");
    }
}